<?php
class NavController extends AdminBaseController  {
	public function lists(){
		$data['list'] = HttpServerManager::getNavServer()->infiniteAllClass(array('id'=>0));
		$news_nav_list = HttpDaoManager::getNewsDao()->getNewIdWithNavId();
		$nav_id_pair = array();
		foreach($news_nav_list as $key=>$value){
			$nav_id_pair[$value['nav_id']] = $value['id'];
		}
		$data['nav_id_pair'] = $nav_id_pair;
		$data['link_type_pair'] = Common::_t('nav_link_type');
		return $data;
	}
	public function add(){
		if (!empty($_GET['id'])){
			$data = HttpDaoManager::getNavDao()->get($_GET['id']);
		
		}
		$data['functions'] = HttpServerManager::getNavServer()->infiniteClass(array('id'=>0));		
		$data['id'] =  Common::getGetStrValue('id');
		$data['father_id'] = isset($data['father_id'])?$data['father_id']:'';
		//$data['banner'] = HttpServerManager::getUploadServer()->eosUploadShow('banner', Common::getStrValue($data, 'banner'));
		$data['linkType'] = Common::_t('nav_link_type');
		$data['newsType'] = Common::_t('news_type');
		$data['newsTypeOption']  = page_modifier_options($data['newsType'],$data['news_type']);
		$data['linkTypeOption']  = page_modifier_options($data['linkType'],$data['link_type']);
		return $data;
	}
	public function subAdd(){
		$data  = $_POST;
		if (!isset($_POST['status'])){
			$data['status'] = 2;
		}
		if (!isset($_POST['news_status'])){
			$data['news_status'] = 2;
		}
		HttpDaoManager::getNavDao()->add($data);
		ClassManager::getToos()->msgbox("添加成功");
	}
	public function subUpdate(){
		$data  = $_POST;
		if (!isset($_POST['status'])){
			$data['status'] = 2;
		}
		if (!isset($_POST['news_status'])){
			$data['news_status'] = 2;
		}		
		HttpDaoManager::getNavDao()->update($data,$_POST['id']);
		ClassManager::getToos()->msgbox("修改成功",'Nav_lists.html');
	}
	public function delete(){
		HttpServerManager::getNavServer()->deleteBatchByid($_GET['id']);
		ClassManager::getToos()->msgbox("删除成功");
	}
}
?>